/*
 ********************************************************************************
 * @FileName  : cfg_param.c
 * @CreateDate: 2021-8-10
 * @Author    : GaoQiu
 * @Copyright : Copyright(C) GaoQiu
 *              All Rights Reserved.
 ********************************************************************************
 */

#include "cfg_param.h"
#include "utils/math.h"
#include "platform/platform.h"

void GetConfigParam(uint8_t paramType, uint8_t *pParam, uint32_t len)
{
	switch(paramType)
	{
	case CFG_PARAM_MAC_ADDR:
	{
		uint32_t tmp = 0;
		FLASH_ReadPage(MAC_ADDR_BASE, (uint8_t *)&tmp, 4);
		if(tmp == 0xFFFFFFFF){
			PrandNums(pParam, len);
			pParam[len-1] |= 0xC0; // static device address;
			FLASH_WritePage(MAC_ADDR_BASE, pParam, len);
		}else{
			FLASH_ReadPage(MAC_ADDR_BASE, pParam, len);
		}
		break;
	}

	default:
		break;
	}
}
